#include "PrecompiledHeader.h"
#include "GuiHud.h"

/*--------------------------------------------------------------------------*/

GuiHud::GuiHud()
{

}

/*--------------------------------------------------------------------------*/

GuiHud::~GuiHud()
{

}

/*--------------------------------------------------------------------------*/

void GuiHud::OnHudUpdate()
{
	for (std::vector<Gui*>::iterator iter = this->m_forms.begin(); iter != this->m_forms.end(); ++iter)
	{
		(*iter)->GetRoot()->Check();
		//(*iter)->GetBox()->CallChildsCheck();
	}
}

/*--------------------------------------------------------------------------*/

void GuiHud::OnHudRender()
{
	for (std::vector<Gui*>::iterator iter = this->m_forms.begin(); iter != this->m_forms.end(); ++iter)
	{
		(*iter)->GetRoot()->Draw();
		//(*iter)->GetBox()->CallChildsDraw();
	}
}

/*--------------------------------------------------------------------------*/

void GuiHud::ClearGui()
{
	this->m_forms.clear();
}

/*--------------------------------------------------------------------------*/

void GuiHud::AddGui(Gui* rgui)
{
	this->DeleteGui(rgui);

	if (rgui != NULL)
	{
		this->m_forms.push_back(rgui);
	}
}

/*--------------------------------------------------------------------------*/

void GuiHud::DeleteGui(Gui* rgui)
{
	for (std::vector<Gui*>::iterator iter = this->m_forms.begin(); iter != this->m_forms.end();)
	{
		if (*iter == rgui)
		{
			iter = this->m_forms.erase(iter);
		}
		else
		{
			++iter;
		}
	}
}

/*--------------------------------------------------------------------------*/

